import Vue from 'vue'
// 获取当前页面的路径并保存
export function getUrl() {
 	  // uni.showToast({
 	  //   icon: "none",
 	  //   title: "您还没有登录,请登录",
 	  // })
	  uni.setStorageSync('token', '')
 	  var pages = getCurrentPages() //获取加载的页面
 	  var currentPage = pages[pages.length - 1] //获取当前页面的对象
 	  var url = currentPage.route //当前页面url
	  uni.setStorageSync("currentUrl", url);
	  uni.setStorageSync("options", currentPage.options);
	  uni.navigateTo({
	  		url: "/pages/login/login",
	  });
 	  // setTimeout(() => {
 		  
 	  // }, 1000);
       //var options = currentPage.options //如果要获取url中所带的参数可以查看options   
       //参数多时通过&拼接url的参数
       // var urlWithArgs = url + '?'
       // for (var key in options) {
       //   var value = options[key]
       //   urlWithArgs += key + '=' + value + '&'
       // }
       // urlWithArgs = urlWithArgs.substring(0, urlWithArgs.length - 1)
       // uni.setStorage({  
       //    key: 'url',
       //    data: `/${urlWithArgs}`
       // })
}
// 登陆后跳转
export function signInJump() {
	const currentUrl = uni.getStorageSync('currentUrl')
	const params = uni.getStorageSync('options')
	const pagurl = ['pages/index/index','pages/class/index','pages/collect/index','pages/shopping/index','pages/my/index']
	if(pagurl.indexOf(currentUrl) === -1){
		// uni.redirectTo({
		// 	url: '/'+currentUrl,
		// });
		Vue.prototype.$u.route({
			type:'redirectTo',
			url: '/'+currentUrl,
			params,
		})
	}else{
		uni.reLaunch({
			url: '/'+currentUrl,
			success() {
			}
		});
	}
}